package com.cn.xiaonuo.tcrfinance.tcrusers.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cn.xiaonuo.tcrfinance.tcrusers.entity.PvWalletLog;
import com.cn.xiaonuo.tcrfinance.tcrusers.mapper.PvWalletLogMapper;
import com.cn.xiaonuo.tcrfinance.tcrusers.service.WalletLogService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Service
public class WalletLogServiceImpl extends ServiceImpl<PvWalletLogMapper, PvWalletLog> implements WalletLogService {

    private static final Logger log = LoggerFactory.getLogger(WalletLogServiceImpl.class);
    @Autowired
    private PvWalletLogMapper walletDao;
    /**
     * 资金变化日志
     */
    @Override
    public synchronized void walletLogs(Integer userId, Integer oderId, BigDecimal beforeMoney, BigDecimal afterMoney, Integer types, String remarks) {
        walletDao.insertWalletLogByUserId(userId, oderId, afterMoney, remarks, LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")), types, userId);
    }

}
